package meatslope2.constants;

import meatslope2.gameengine.gameobjects.Tile;
import meatslope2.gameengine.primatives.LineSegment;
import meatslope2.gameengine.primatives.Vector2;

/**
 * Include index for each static tile to hardcode for level building in code
 * 
 * @author Mitchell Thelen
 *
 */
public final class TileConstants 
{
	// ===========================================================
	// Constants
	// ===========================================================
	private static final Tile.Builder builder = new Tile.Builder();
	
	public static final int NOT_SET = -1;
	
	public static final Tile BLOCK =
			builder.setIndex(0)
			.setSprite(SpriteConstants.BLOCK)
			
			//Left line segment
			.addLineSegment(new LineSegment(
					new Vector2(0,0), //start
					new Vector2(0, BitmapConstants.TILE_HEIGHT), //end
							new Vector2(-1, 0))) //normal
							
			//Bottom line segment
			.addLineSegment(new LineSegment(
					new Vector2(0,0), //start
					new Vector2(BitmapConstants.TILE_WIDTH, 0), //end
							new Vector2(0, -1))) //normal
							
			.addLineSegment(new LineSegment(
					new Vector2(BitmapConstants.TILE_WIDTH, 0), //start
					new Vector2(BitmapConstants.TILE_WIDTH, BitmapConstants.TILE_HEIGHT), //end
							new Vector2(1, 0))) //normal
							
			//Top LineSegment
			.addLineSegment(new LineSegment(
					new Vector2(-10, BitmapConstants.TILE_HEIGHT), //start
					new Vector2(BitmapConstants.TILE_WIDTH + 10, BitmapConstants.TILE_HEIGHT), //end
							new Vector2(0, 1))) //normal
			.build();
	
	public static final Tile RAMP_LEFT_1 = 
			builder.setIndex(1)
			.setSprite(SpriteConstants.RAMP_LEFT_1)
			.addLineSegment(new LineSegment(
					new Vector2(0,0), //start
					new Vector2(BitmapConstants.TILE_WIDTH, BitmapConstants.TILE_HEIGHT / 2), //end
							new Vector2(-1, 2))) //normal
			.build();
	
	public static final Tile RAMP_LEFT_2 = 
			builder.setIndex(2)
			.setSprite(SpriteConstants.RAMP_LEFT_2)
			.addLineSegment(new LineSegment(
					new Vector2(0, BitmapConstants.TILE_HEIGHT / 2), //start 
					new Vector2(BitmapConstants.TILE_WIDTH, BitmapConstants.TILE_HEIGHT), //end
					new Vector2(-1, 2))) //normal
			.build();
	
	public static final Tile RAMP_RIGHT_1 = 
			builder.setIndex(3)
			.setSprite(SpriteConstants.RAMP_RIGHT_1)
			.addLineSegment(new LineSegment(
					new Vector2(0, BitmapConstants.TILE_HEIGHT / 2), //end
					new Vector2(BitmapConstants.TILE_WIDTH, 0), //start
					new Vector2(1, 2))) //normal
			.build();
	
	public static final Tile RAMP_RIGHT_2 = 
			builder.setIndex(4)
			.setSprite(SpriteConstants.RAMP_RIGHT_2)
			.addLineSegment(new LineSegment(
					new Vector2(0, BitmapConstants.TILE_HEIGHT), //start 
					new Vector2(BitmapConstants.TILE_WIDTH, BitmapConstants.TILE_HEIGHT / 2), //end
					new Vector2(1, 2))) //normal
			.build();
	
	// ===========================================================
	// Members
	// ===========================================================	
	private static Tile[] tiles = new Tile[]
	{
		BLOCK,
		RAMP_LEFT_1,
		RAMP_LEFT_2,
		RAMP_RIGHT_1,
		RAMP_RIGHT_2
	};

	// ===========================================================
	// Methods
	// ===========================================================
	public static Tile getTile(int index)
	{
		return tiles[index];
	}
}
